﻿using System;
using System.Collections.Concurrent;
namespace MvcFlow.Extensions
{
    public class ConcurrentBookmarkOutputExtension : IBookmarkOutputExtension
    {
        private readonly ConcurrentDictionary<string,object> bookmarkValues = new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase);

        public object GetBookmarkValue(string bookmarkName)
        {
            object result = null;
            return bookmarkValues.TryGetValue(bookmarkName,out result) ? result : null;
        }

        public void SetBookmarkValue(string bookmarkName, object value)
        {
            bookmarkValues[bookmarkName] = value;
        }
    }
}